FROM alpine:3.5

COPY plugins/ /etc/fluentd/plugins/


RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
  apk update && apk upgrade && \
  apk add tzdata && \
  apk add ruby-json ruby-irb && \
  apk add build-base ruby-dev && \
  apk add python && \
  apk add lsof && \
  apk add ca-certificates wget && \
  gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/ && \
  gem install fluentd -v "0.12.42" --no-ri --no-rdoc && \
  gem install --local /etc/fluentd/plugins/gelf-3.0.1.gem --no-ri --no-rdoc && \
  gem install fluent-plugin-record_splitter -v "0.1.3" --no-ri --no-rdoc && \
  gem install remote_syslog_logger -v "1.0.1" --no-ri --no-rdoc && \
  gem install fluent-plugin-remote_syslog -v "0.2.1" --no-ri --no-rdoc && \
  apk del build-base ruby-dev && \
  ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
  rm -rf /root/.gem


VOLUME /etc/fluentd/conf.d

COPY gdocker-fluent fluentd.tpl entrypoint config.default /pilot/
VOLUME /pilot/pos

EXPOSE 24224
WORKDIR /pilot/
#CMD exec fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT
CMD /pilot/entrypoint
